#ifndef MSGTHREAD_H
#define MSGTHREAD_H

#include <QThread>
#include "chatdbhandler.h"
#include <winsock2.h>
#include <iostream>
#include <string>
#include <vector>
#include <socktooler.h>
#include "createmymsg.h"
using namespace std;


class MsgThread : public QThread{
  Q_OBJECT
public :
    MsgThread(SOCKET receive, SOCKET send_s, ChatDbHandler *db);
    void run();
    void DealMsg(TransMsg trans_msg);
signals :
    void MessageComing(const TransMsg &msg);
    void HeartBComing(const TransMsg &msg);
    void RegistComing(string name);

public slots :

    void IsMyMsg(const TransMsg &msg);
    void SendRspHeartB(string content);

private:
    SOCKET receive_sock;
    SOCKET send_sock;
    ChatDbHandler *chat_db;
    string socket_user_name;
    void DealReqLogin(const TransMsg &msg);
    void DealReqRegist(const TransMsg &msg);
    void DealMessage(TransMsg &msg);
    void DealReqHeartB(const TransMsg &msg);
};

#endif // MSGTHREAD_H
